package com.xx.job.controller.system;


import com.xx.job.common.Result;
import com.xx.job.entity.system.SysDept;
import com.xx.job.mapper.SysDeptMapper;
import com.xx.job.service.system.SysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import com.xx.job.controller.base.BaseController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liangcy
 * @since 2021-01-14
 */
@RestController
@RequestMapping("/api/v1")
public class SysDeptController extends BaseController {

    @Autowired
    private SysDeptService sysDeptService;

    @RequestMapping("/deptTree")
    public Result deptTree(){
       return Result.success(sysDeptService.deptTree());
    }

    @GetMapping("/deptList")
    public Result deptList(){
        return Result.success(sysDeptService.deptTree());
    }


    @PostMapping("/dept")
    public Result addDept(@RequestBody SysDept sysDept){
        return Result.success(sysDeptService.add(sysDept));
    }

    @GetMapping("/dept/{id}")
    public Result selectDept(@PathVariable Long id){
        return Result.success(sysDeptService.selectSysDept(id));
    }

    @DeleteMapping("/dept/{id}")
    public Result delectDdept(@PathVariable Long id){
        return Result.success(sysDeptService.delect(id));
    }

    @PutMapping("/dept")
    public Result updateDept(@RequestBody SysDept sysDept){
        return Result.success(sysDeptService.update(sysDept));
    }

}

